package com.jiyilee;

import com.jiyilee.schema.SchemaExportTool;
import org.hibernate.cfg.ImprovedNamingStrategy;
import org.hibernate.tool.hbm2ddl.MySchemaExport;

import java.util.Properties;

/**
 * Hello jiyilee!
 */
public class App {
    public static void main(String[] args) {
        System.out.println("Hello Az!");
        try {
            Properties p = new Properties();
            p.setProperty("hibernate.dialect",
                    "org.hibernate.dialect.MySQLDialect");
            SchemaExportTool cfg = new SchemaExportTool();
            cfg.addProperties(p);
            cfg.setNamingStrategy(new ImprovedNamingStrategy());
            cfg.scanPackage("com.jiyilee.database.entity");

            MySchemaExport se = new MySchemaExport(cfg);
            if (null != args && args.length > 1)
                if ("-f".equals(args[0]))
                    se.setOutputFile(args[1]);
                else
                    se.setOutputFile("create_table.sql");
            else
                se.setOutputFile("create_table.sql");
            se.setDelimiter(";");
            // se.drop(false, false);
            se.create(false, false);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
